import { defineConfig } from 'vite';
import legacy from '@vitejs/plugin-legacy';
import { resolve } from 'path';

export default defineConfig({
  plugins: [
    legacy({
      targets: ['defaults', 'not IE 11']
    })
  ],
  build: {
    lib: {
      entry: resolve(__dirname, 'src/index.js'),
      name: 'FrontUtils',
      fileName: (format) => `front-utils.${format}.js`
    },
    outDir: 'lib',
    sourcemap: true,
    rollupOptions: {
      output: [
        {
          format: 'es',
          entryFileNames: 'front-utils.es.js',
          preserveModules: true,
          dir: 'lib/es'
        },
        {
          format: 'cjs',
          entryFileNames: 'front-utils.cjs.js',
          dir: 'lib/cjs'
        },
        {
          format: 'umd',
          name: 'FrontUtils',
          entryFileNames: 'front-utils.umd.js',
          dir: 'lib/umd'
        }
      ]
    }
  }
}); 